package com.hzdl.flower.service.impl;


import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hzdl.flower.bean.Flower;
import com.hzdl.flower.mapper.FlowerMapper;
import com.hzdl.flower.service.FlowerService;
import com.hzdl.flower.util.PageUtil;
import com.hzdl.flower.vo.FlowerVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class FlowerServiceImpl implements FlowerService {

    @Autowired
    private FlowerMapper flowerMapper;

    @Override
    public List<Flower> findFlower(FlowerVo flowerVo) {
        return flowerMapper.findFlower(flowerVo);
    }

    @Override
    public List<Flower> findNew(FlowerVo flowerVo) {

        return flowerMapper.findNew(flowerVo);

    }

    @Override
    public List<Flower> findhot(FlowerVo flowerVo) {

        return flowerMapper.findhot(flowerVo);

    }

    @Override
    public Flower findById(FlowerVo flowerVo) {
        return flowerMapper.findById(flowerVo);
    }

    @Override
    public int countAll(FlowerVo flowerVo) {

        return flowerMapper.countAll(flowerVo);
    }
    @Override
    public PageInfo findPage(Map<String,Object> map,Integer startIndex, Integer pagesize) {
        Page<Object> objects = PageHelper.startPage(startIndex, pagesize);
        List<Flower> pageFlowers = flowerMapper.findPageFlower(map);
        PageInfo pageInfo = new PageInfo(pageFlowers);
        return pageInfo;
    }

    @Override
    public List<Flower> findByTypeAndColor(Integer type, String color) {

        return flowerMapper.findByTypeAndColor(type,color);

    }


}
